<template>
  <div class="snConter">
    <div class="title flex">
      <div class="title_icon" @click="gotoback"><i class="el-icon-arrow-left"></i></div>
      <div class="text">查询结果</div>
    </div>
    <el-collapse accordion >
      <el-collapse-item v-for="item in snValue" :key="item.value"  style="margin-top:20px;border-radius:6px;overflow:hidden">
        <template slot="title">
          <div class="flex flex_bet" style="width:90%"  @click="getquerySnAppInfo(item)">
            <div class="flod_title flex felx_align">
              <img style="height:30px" src="@/assets/images/pingb.png" alt="">
              <span>{{item.username}} ( {{item.value}} )</span>
            </div>
            <div >查看设备信息</div>
          </div>
        </template>
        <div class="snCenter">
          <div class="snCity flex felx_align">
            <img src="@/assets/images/city.png" alt="" style="height:30px;width:30px">
            {{app_install.address}}
          </div>
          <table style="width:100%">
            <tr>
              <th style="text-align: left;">应用名</th>
              <th>运行状态</th>
              <th>安装时间</th>
            </tr>
            <tr v-for="(item,index) in app_install.app" :key="index">
              <td class="flex felx_align">
                <div class="app-img"><img :src="item.app_img" alt=""></div>
                <div>{{item.app_name}}</div>
              </td>
              <td style="text-align:center"><i class="iconfont icondian3" :class="item.state ? 'on_line' : 'off_line'"></i></td>
              <td style="text-align:center">{{item.install_time | newDate}}</td>
            </tr>
          </table>
        </div>
      </el-collapse-item>
    </el-collapse>
  </div>
</template>

<script>
import { queryPhoneSn, querySnAppInfo } from "@/api/wxAccounts.js";
export default {
  data() {
    return {
      snValue: [],
      app_install: []
    }
  },
  created() {
    console.log("参数", this.$route.query.phone)
    this.getqueryPhoneSn(this.$route.query.phone)
  },
  methods: {
    getqueryPhoneSn(phone) {
      queryPhoneSn({ phone: phone }).then(res => {
        this.snValue = res.data
        console.log('1111', this.snValue)
      }).catch(err => {

      })
    },
    getquerySnAppInfo(item) {
      this.app_install = []
      console.log('是否触发', item)
      querySnAppInfo({ sn: item.value }).then(res => {
        this.$nextTick(() => {
          this.app_install = res.data
        })
      }).catch(err => {
       this.$nextTick(() => {
          this.app_install = []
        })
      })
    }, 
    gotoback() {
        this.$router.go(-1)
    }
  }
}
</script>

<style lang="scss" scoped>
.snConter {
  height: 100%;
  background-image: -webkit-linear-gradient(90deg, #0079ff 0%, #00bcff 100%);
  padding: 40px 10px;
  .title {
    color: #fff;
    font-size: 22px;
    font-weight: 600;
    margin-bottom:50px;
    .text {
      width: 100%;
      text-align: center;
    }
    .title_icon {
      i {
        font-size: 22px;
        font-weight: 600;
      }
    }
  }

  .flod_title {
    margin-left: 10px;
    span {
      margin-left: 5px;
      font-weight: 600;
    }
  }
  table {
    color: #999;
    width: 100%;
    font-size: 14px;
    border-collapse: collapse;
    th {
      text-align: center;
      font-weight: 500;
      color: #232323;
      padding-left: 20px;
      font-size: 12px;
    }
    tr {
      line-height: 40px;
      height: 40px;
      padding: 0 20px;
      border-bottom: 1px solid #e5e5e5;
      td {
        padding-left: 20px;
        font-size: 12px;
        text-align: center;
        .app-img {
          height: 30px;
          width: 30px;
          margin-right: 5px;
          img {
            height: 100%;
            width: 100%;
          }
        }
      }
    }
  }
  table tr:last-child {
    border: none;
  }
  .on_line {
    color: #8fc31f;
  }
}
</style>

<style scoped>
/deep/ .el-collapse-item__arrow {
  color: #2b8bff;
  font-weight: 900;
  font-size: 18px;
}
</style>